import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/index'
import Vant, {
  Toast
} from 'vant';
import 'vant/lib/index.css';
// 加载重置样式和公共样式
import './assets/style/reset.css';
import './assets/style/common.css';
import 'amfe-flexible';

import $axios from '@/utils/request';
Vue.prototype.$axios = $axios;


Vue.use(Vant);
Vue.config.productionTip = false

import mixin from './mixin/index';
Vue.mixin(mixin);

// 注册全局组件,必须放在vue实例之前
Vue.component('base-checkbox', {
  model: {
    prop: 'checked',
    event: 'change'
  },
  props: {
    checked: Boolean
  },
  template: `
    <input
      type="checkbox"
      v-bind:checked="checked"
      v-on:change="$emit('change', $event.target.checked)"
    >
  `
})

Vue.filter('formatDate', function (time) {
  let date = new Date(time);
  let Y = date.getFullYear();
  let M = date.getMonth() + 1;
  let D = date.getDate();

  Y = Y < 10 ? "0" + Y : Y;
  D = D < 10 ? "0" + D : D;
  return `${Y}-${M}-${D}`;
})



new Vue({
  // 把router挂载到vue实例
  router,
  store,
  render: h => h(App),
}).$mount('#app')